package com.chenglu.android.order.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;


import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023 6 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description： 文字标题的adapter
 */
public class TabTitleAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context mcontext ;

    

    public TabTitleAdapter(@Nullable Context context, List<String> data) {
        super(R.layout.item_title_supply, data);
        this.mcontext = context;

    }



    @Override
    protected void convert(@NonNull BaseViewHolder helper, String item) {

        if (item != null) {

            TextView textView = helper.getView(R.id.tv_item_title);
            ImageView imageView = helper.getView(R.id.iv_item_supply);

            textView.setText(item);

            if(helper.getAdapterPosition()==getthisPosition()){
                imageView.setBackground(mcontext.getResources().getDrawable(R.drawable.supply_icon_select));
                imageView.setVisibility(View.VISIBLE);
            }else {
//                imageView.setBackground(mcontext.getResources().getDrawable(R.drawable.supply_icon_select));
                imageView.setVisibility(View.INVISIBLE);
            }


        }

    }

    //先声明一个int成员变量,若为0默认显示第一个
    private int thisPosition = 0;

    //再定义一个int类型的返回值方法
    public int getthisPosition() {
        return thisPosition;
    }

    //   传入点击的位置
    public void setThisPosition(int thisPosition) {
        this.thisPosition = thisPosition;
        notifyDataSetChanged();
    }
}
